<script src="static/plugins/swfupload/swfupload.js" type="text/javascript"></script>
<script src="static/plugins/swfupload/swfupload.queue.js" type="text/javascript"></script>
<script src="static/plugins/swfupload/fileprogress.js" type="text/javascript"></script>
<script src="static/plugins/swfupload/handlers.js" type="text/javascript"></script>
<link href="static/plugins/swfupload/process.css" rel="stylesheet" type="text/css"/>
<script src="static/cms/js/autoZoomLoadImage.js" type="text/javascript"></script>

<script type="text/javascript">
	function doSearchCmsVentureServiceArea(value) {
		
	}
	
	//表格查询  
	function reloadCmsVentureServiceArea() {
		var params = cmsVentureServiceArea_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		cmsVentureServiceArea_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		cmsVentureServiceArea_list.datagrid('unselectAll');
		cmsVentureServiceArea_list.datagrid('uncheckAll');
	}


	function addCmsVentureServiceArea() {
		createFromWindow("新增信息", "cmsVentureServiceArea.do?editCmsVentureServiceArea", "cmsVentureServiceArea.do?saveCmsVentureServiceArea",
				function(data) {
					reloadCmsVentureServiceArea();
				});
	}
	
	function deleteCmsVentureServiceArea() {
		var rows = cmsVentureServiceArea_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('cmsVentureServiceArea.do?deleteCmsVentureServiceAreaItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadCmsVentureServiceArea();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editCmsVentureServiceArea() {
		var rows = cmsVentureServiceArea_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "cmsVentureServiceArea.do?editCmsVentureServiceArea&cmsVentureServiceAreaId=" + rows[0].id,
					"cmsVentureServiceArea.do?saveCmsVentureServiceArea", function(data) {
						reloadCmsVentureServiceArea();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	function clearCmsVentureServiceAreaSearch() {
		setGridSearchParams('cmsVentureServiceArea_list','cmsVentureServiceAreaSearchForm',true,reloadCmsVentureServiceArea);
	}
	
	//根据条件查询
	function cmsVentureServiceAreaSearch() {
		setGridSearchParams('cmsVentureServiceArea_list','cmsVentureServiceAreaSearchForm',false,reloadCmsVentureServiceArea);
	}
	
	function onDblClickCmsVentureServiceAreaRow(rowIndex, rowData) {
		createFromWindow("编辑信息", "cmsVentureServiceArea.do?editCmsVentureServiceArea&cmsVentureServiceAreaId=" + rowData.id,
					"cmsVentureServiceArea.do?saveCmsVentureServiceArea", function(data) {
						reloadCmsVentureServiceArea();
					},true);
	}
	
	//发布活动动态
	function publishAct() {
		var rows = cmsVentureServiceArea_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"新增活动动态",
				maximizable:true,
				width:document.body.clientWidth,
				height:document.body.clientHeight,
				href:"cmsContent.do?editCmsContent&navCode=yqjd",
				callback:function(d) {
					var rowData2 = d.form("getData");
					var ckData = CKEDITOR.instances.cmsContentTxt.getData();
					var formData = d.form("getData");
					formData.contentTxt = ckData;
					var uploadImgName = "";
					var selectTitleImg = "";
					$("input[name='uploadImgName']").each(function(){
				         uploadImgName += ','+jQuery(this).val();
				         var checkTitleImgId = 'seltype0'+jQuery(this).attr("index");
				         printLog($('#'+checkTitleImgId).attr("checked"));
				         if($('#'+checkTitleImgId).attr("checked")) {
				        	 selectTitleImg = jQuery(this).val();
				         }
					});
					
					var attPaths = "";
					var attNames = "";
					$("input[name='attPaths']").each(function(){
						attPaths += ','+jQuery(this).val();
						attNames += ','+jQuery(this).attr('fileName');
					});
					formData.attNames = attNames;
					formData.attPaths = attPaths;
					formData.selectTitleImg = selectTitleImg;
					formData.uploadImgName = uploadImgName;
					printLog(formData);
					$.ajax({
		           	  type: 'POST',
		           	  url: "cmsContent.do?saveCmsContent",
		              dataType : 'json',  
		           	  data: formData,
		           	  success: function(data) {
		           		  showMsg(data.msg);
		           		  if(data.success) {
		           			reloadCmsContent();
			           	  }
		           	  },
			          error:function(data,textstatus){  
			        	  printLog(data);
			        	  showMsg('请求异常');
			           }  
		           	});
					
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择操作记录.');
		}
	}
	
	
	function addProject() {
		var rows = cmsVentureServiceArea_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"入驻项目",
				maximizable:true,
				width:1100,
				height:600,
				href:"cmsVentureServiceArea.do?selectPage=chooseEntreComponent&areaId="+rows[0].id,
				callback:function(data) {
// 					alert($('#cmsEntreSelectInfo').val());
		    		$.post("cmsVentureServiceArea.do?saveSetEntreSelect", {areaId:rows[0].id,entreIds:$('#cmsEntreSelectInfo').val()}, function(result) {
		    	          if(result.success){
		    		       	  showMsg('保存成功.');
		    	          }else {
		    	       	  	  showMsg('保存失败.');
		    	          }
		    	  	}, "JSON");
				},
				enableSaveButton:true
			});
		}
		else {
			showMsg('请选择操作记录.');
		}
		
	}
	
	function bestInstructor() {
		var rows = cmsVentureServiceArea_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"优秀导师",
				maximizable:true,
				width:1100,
				height:600,
				href:"cmsVentureServiceArea.do?selectPage=chooseInstructorComponent&areaId="+rows[0].id,
				callback:function(data) {
		    		$.post("cmsVentureServiceArea.do?saveSetInstructorSelect", {areaId:rows[0].id,instructorIds:$('#cmsInstrSelectInfo').val()}, function(result) {
		    	          if(result.success){
		    		       	  showMsg('保存成功.');
		    	          }else {
		    	       	  	  showMsg('保存失败.');
		    	          }
		    	  	}, "JSON");
				},
				enableSaveButton:true
			});
		}
		else {
			showMsg('请选择操作记录.');
		}
	}
</script>


<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="cmsVentureServiceArea_list" toolbar="#cmsVentureServiceArealist_search" idField="id"  url="cmsVentureServiceArea.do?loadList" rownumbers="true" onDblClickRow="onDblClickCmsVentureServiceAreaRow(rowIndex, rowData)"
			 item="com.xdtech.cms.vo.CmsVentureServiceAreaItem"/>
		
		<div id="cmsVentureServiceArealist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="cmsVentureServiceAreaSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					
					<input id="cmsEntreSelectInfo" name="cmsEntreSelectInfo" type="hidden" />
					<input id="cmsInstrSelectInfo" name="cmsInstrSelectInfo" type="hidden" />
					
					<table>
						<tr>
							<td>名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" style="width: 150px"/></td>
							<td>所属类型：</td>
							<td><@eu.comboBox name="areaType" url="common.do?loadComboBox&key=CMS_AREA_TYPE" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="cmsVentureServiceAreaSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearCmsVentureServiceAreaSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
			</div>
			<div id="cmsVentureServiceArea_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="cms:cmsVentureServiceArea:add" iconCls="icon-add" onclick="addCmsVentureServiceArea()"/>
				<@eu.linkbutton showName="删除" shiro="cms:cmsVentureServiceArea:delete" iconCls="icon-remove" onclick="deleteCmsVentureServiceArea()"/>
				<@eu.linkbutton showName="编辑" shiro="cms:cmsVentureServiceArea:edit" iconCls="icon-edit" onclick="editCmsVentureServiceArea()"/>
				<@eu.linkbutton showName="发布活动" shiro="cms:cmsVentureServiceArea:publishAct" iconCls="icon-edit" onclick="publishAct()"/>
<!-- 				<@eu.linkbutton showName="查看活动" shiro="cms:cmsVentureServiceArea:publishActList" iconCls="icon-edit" onclick="publishActList()"/> -->
				<@eu.linkbutton showName="入驻项目" shiro="cms:cmsVentureServiceArea:addProject" iconCls="icon-edit" onclick="addProject()"/>
<!-- 				<@eu.linkbutton showName="项目列表" shiro="cms:cmsVentureServiceArea:addProjectList" iconCls="icon-edit" onclick="addProjectList()"/> -->
<!-- 				<@eu.linkbutton showName="新增优秀导师" shiro="cms:cmsVentureServiceArea:bestInstructor" iconCls="icon-edit" onclick="bestInstructor()"/> -->
				<@eu.linkbutton showName="优秀导师" shiro="cms:cmsVentureServiceArea:bestInstructorList" iconCls="icon-edit" onclick="bestInstructor()"/>
				
				<@eu.linkbutton showName="刷新" shiro="cms:cmsVentureServiceArea:refresh" iconCls="icon-reload" onclick="reloadCmsVentureServiceArea()"/>
			</div>
		</div>
	</div>
</div>